home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CDsupport / IDer / Routines / LaunchAction.s < prev    next >
Text File  |  1997-02-18  |  6KB  |  144 lines

  1. LaunchAction:    Clr.W    _ErrorCode        ;there _shouldn't_ be any errors with this routine
  2.  
  3.     Tst.B    _Successful        ;did one of the check routines succeed?
  4.     Bne.S    .Successful        ;if so, then run the commandline
  5.  
  6.     Tst.L    _Suffix        ;the following six lines are simply to make
  7.     Bne    CheckLoop        ;sure that only the DEFUALT class is run
  8.     Tst.L    _Name        ;if none of the check routines actually
  9.     Bne    CheckLoop        ;managed to match anything out of the file
  10.     Tst.L    _Offset
  11.     Bne    CheckLoop
  12.     Bra.S    Launch
  13.  
  14. .Successful    Cmp.B    #MODE_TWO,_Mode        ;does the command require at least two correct entries
  15.     Bne.S    Launch        ;if not, then ignore the check
  16.     Cmp.B    #2,_Successful        ;is the number of correct entries greater or equal to 2
  17.     Blt    CheckLoop        ;if not, then check for a new class
  18.  
  19. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  20. Launch:    Tst.L    _WBMessage        ;were we launhced from workbench?
  21.     Beq.S    .NoWB        ;if not, ignore the following
  22.     CloneWbPath    _WBMessage(PC)        ;get workbench paths
  23.     Move.L    D0,_WBPaths        ;save this for use in NP_Path
  24.  
  25. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  26. .NoWB    Lea    _SystemTags,A4        ;list of custom options for the launching of programs
  27.  
  28.     Move.L    _Stack(PC),D1        ;was STACK available
  29.     Tst.L    D1        ;was the tag actually mentioned in the class config
  30.     Beq.S    .NoStack
  31.  
  32.     Move.L    #WorkData,D2        ;and a place to strore a number
  33.     CALL    StrToLong,DOS        ;convert the string into a longword
  34.     Cmp.L    #-1,D0        ;fail if something went wrong
  35.     Beq.S    .NoStack        ;but don't set the tag to anything
  36.  
  37.     Move.L    #NP_StackSize,(A4)+    ;the tag ID for the stack
  38.     Move.L    WorkData,(A4)+        ;the amount of stack to allocate
  39. .NoStack
  40. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  41.     Move.L    _Pri(PC),D1        ;was PRI found in the class entry
  42.     Tst.L    D1
  43.     Beq.S    .NoPri        ;if not, skip the tag entry
  44.  
  45.     Move.L    #WorkData,D2        ;and a place to strore a number
  46.     CALL    StrToLong,DOS        ;convert the string into a longword
  47.     Cmp.L    #-1,D0        ;fail if something went wrong
  48.     Beq.S    .NoPri        ;but don't set the tag to anything
  49.  
  50.     Move.L    WorkData,D0        ;value returned by StrToLong()
  51.     Cmp.L    #127,D0        ;maximum of 127
  52.     Bgt.S    .NoPri        ;no entry if they mucked up
  53.     Cmp.L    #-127,D0        ;minimum of -127
  54.     Blt.S    .NoPri        ;again, skip it if they put in a wrong number
  55.  
  56.     Move.L    #NP_Priority,(A4)+    ;the tag ID for PRI
  57.     Move.L    D0,(A4)+        ;the number we got from the class entry
  58. .NoPri
  59. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  60.     Move.L    _WBPaths(PC),D0        ;is there an entry from CloneWbPath()
  61.     Tst.L    D0
  62.     Beq.S    .NoPaths        ;if not, then skip the tag entry
  63.  
  64.     Move.L    #NP_Path,(A4)+        ;the tag ID for a custom path setting
  65.     Move.L    D0,(A4)+        ;the paths returned by Ralph's routines
  66. .NoPaths
  67. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  68.     Move.L    #TAG_DONE,(A4)        ;end of the list
  69.  
  70. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  71.     Move.L    _OutputBuffer(PC),A1    ;clean up the memory allocated to hold
  72.     Move.L    _OutputBufLen(PC),D0    ;the data file so the user actually has
  73.     Cmp.L    #0,A1        ;some memory to work with when they try
  74.     Beq.S    .NoFileMemory        ;to view the file
  75.     CALL    FreeMem,EXEC
  76.     Clr.L    _OutputBuffer        ;clear data space so we don't try and free it upon exit
  77. .NoFileMemory
  78.  
  79. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  80.     Move.L    _Action(PC),A0        ;the program to run, as provided by the class entry
  81.     Lea    CommandLine,A1        ;space to hold the final commandline
  82. .CopyAction    Move.B    (A0)+,D0        ;copies a string
  83.     Cmp.B    #'%',D0        ;was a % found in the string
  84.     Bne.S    .IgnorePercent        ;if not, then don't insert the filename
  85.  
  86. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  87.     Move.B    (A0),D0        ;get the character after the %
  88.     Cmp.B    #'s',D0        ;is it an s for string (ie, insert filename here)
  89.     Bne.S    .IgnorePercent        ;if not, then don't insert the filename
  90.  
  91.     Tst.B    _Quote        ;are we ment to include quotes
  92.     Bne.S    .NoFNQuote        ;if not then jump to the copy routine
  93.     Move.B    #'"',(A1)+        ;insert a quote
  94.  
  95. .NoFNQuote    Move.L    _FileName(PC),A2    ;the filename specified
  96.     Addq    #1,A0        ;jump over the s in the action line
  97. .CopyFName    Move.B    (A2)+,D0        ;gets a character
  98.     Move.B    D0,(A1)+        ;puts it into the final commandline
  99.     Bne.S    .CopyFName        ;if it wasn't the end, then get another character
  100.     Moveq    #1,D1        ;mark that we have already inserted the filename into the commandline
  101.  
  102.     Subq    #1,A1
  103.  
  104.     Tst.B    _Quote        ;do we have to insert a quote
  105.     Bne.S    .CopyAction        ;if not, then carry on with the rest of the action entry
  106.     Move.B    #'"',(A1)+        ;replace the space with a "
  107.     Bra.S    .CopyAction        ;carry on copying the rest of the action entry
  108.  
  109. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  110. .IgnorePercent    Move.B    D0,(A1)+        ;put the character into the command stream
  111.     Bne.S    .CopyAction        ;if it wasn't a zero, then go get another charcter
  112.  
  113.     Cmp.B    #1,D1        ;have we already inserted the filename
  114.     Beq.S    .No2ndAction        ;if so, then don't do it again
  115.     Move.B    #' ',-1(A1)        ;place a space after the command
  116.  
  117.     Tst.B    _Quote        ;quote needed?
  118.     Bne.S    .NoFNQuote2        ;if not, then don't put one in
  119.     Move.B    #'"',(A1)+        ;throw a quote in before the start of the filename
  120.  
  121. .NoFNQuote2    Move.L    _FileName(PC),A0    ;the name of the file to be viewed
  122.     Bsr    StripQuotes        ;copy the filename into the final commandline
  123.  
  124.     Tst.B    _Quote        ;quote needed to clean things up?
  125.     Bne.S    .No2ndAction        ;if not, then don't put one in
  126.     Move.B    #'"',-1(A1)        ;close the pair of quotes surrounding the filename
  127. .No2ndAction    Clr.B    (A1)        ;mark the end of the commandline
  128.  
  129. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  130.     Move.L    #CommandLine,D1        ;the commandline to be run
  131.     Move.L    #_SystemTags,D2        ;any special tags to be attached to the newly created Process
  132.     CALL    SystemTagList,DOS    ;run the commandline
  133.  
  134. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  135.     Cmp.L    #-1,D0        ;did System() return an error
  136.     Bne.S    .NoWBPaths        ;if not, then don't worry about cleaning up any possible paths
  137.  
  138.     Tst.L    _WBPaths        ;if we were launched from workbench then the paths should have been set
  139.     Beq.S    .NoWBPaths        ;if not, then don't try and free them up
  140.     FreeWbPath    _WBPaths(PC)        ;free up the workbench paths using Ralph's routine
  141.  
  142. .NoWBPaths
  143.     Clr.L    _WBPaths        ;clear the paths entry if we are going to use it again later on
  144.